<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/vectrics.tld"    prefix="vectrics" %>


<%@ page import="org.vectrics.security.*" %>
<%@ page import="org.vectrics.user.*" %>
<%@ page import="org.vectrics.struts.*" %>
<%
	Request vectricsRequest = HttpRequestConverter.convertRequest(request);

	Person authPerson = PrivilegeUtils.getAuthPerson(vectricsRequest);
	String companyPersonId = request.getParameter("companyPersonId");
	if ((companyPersonId == null) || (companyPersonId.length() == 0)) {
		companyPersonId = (String)request.getAttribute("companyPersonId");
	}
	String domainId = request.getParameter("domainId");
	String companyId = request.getParameter("companyId");
	String personId = request.getParameter("personId");
	if ((personId == null) || (personId.length() == 0)) {
		personId = (String)request.getAttribute("personId");
	}
%>

<jsp:useBean id="companyPersonPrivilegeForm" class="org.vectrics.company.web.struts.CompanyPersonPrivilegeForm" scope="request"/>

<vectrics:errors debug="false"/>

<html:form action="/admin/company/person/priv/save" method="POST"  focus="name">
	<vectrics:userRolesSelect personId="<%=personId%>" global="true" domainId="<%=domainId%>" companyId="<%=companyId%>" hidden="true"/>
	<html:hidden property="companyId"/>
	<html:hidden property="domainId"/>
	<html:hidden property="personId"/>
	<font><b>Company:</b>&nbsp<bean:write name="companyPersonPrivilegeForm" property="companyName"/></font>
	<br>
	<font><b>Person:</b>&nbsp<bean:write name="companyPersonPrivilegeForm" property="personName"/></font>
	<br>
	<table>

			<% 
				// Make sure user has privileges to edit roles.
				if (PrivilegeUtils.hasPrivilege("can.edit.role", authPerson)) {    
			%>
					<tr>
						<td valign="TOP" colspan="3"><br><h3><bean:message key="heading.person.roles.and.groups"/></h3></td>
					</tr>
					<tr>
						<td class="formBg2" valign="top" width="150"><font class="formLabelClass"><bean:message key="prompt.user.roles"/></font></td>
						<td class="formBg2" valign="top"><vectrics:userRolesSelect personId="<%=personId%>" global="true" domainId="<%=domainId%>" hidden="false"/></td>
						<td></td>
					</tr>
			<% } else {%>
				<h3>Insufficient privileges to setup user privileges.</h3>
			<% } %>

		
					<tr>
						<td valign="TOP" align="left"></td>
						<td valign="TOP" align="left">
							<vectrics:formButton code="button.ok" phraseCode="button.ok" 
								elementId="ok.btn"
								value="submit" name="submit"/>&nbsp;
							<vectrics:formButton code="button.cancel" phraseCode="button.cancel" 
								elementId="cancel.btn"
								value="cancel" name="cancel"/>
						</td>
					</tr>
	</table>
</html:form>
